package newfeature.jdk8;

import java.lang.reflect.Method;
import java.lang.reflect.Parameter;

/**
 * Created by dl
 */
public class MethodParameterReflection {
	public static void main(String[] args) throws NoSuchMethodException {
		// compile with option '-parameters', off by default
		Method method = MethodParameterReflection.class.getMethod("sum", int.class, int.class);
		Parameter[] parameters = method.getParameters();
		for (Parameter parameter : parameters) {
			System.out.println("parameter.getName() = " + parameter.getName());
		}
	}

	public int sum(int a, int b) {		// names will be arg0,arg1 if compiled without '-parameters'
		return a+b;
	}
}
